<template>
  <el-col :span="22" :offset="1">
    <el-card>
      <el-table
        :data="uploadFileLogs"
        style="width: 100%"
        max-height="370">
        <el-table-column
          fixed
          prop="sId"
          label="主管id"
          width="auto">
        </el-table-column>
        <el-table-column
          prop="pId"
          label="项目id"
          width="auto">
        </el-table-column>
        <el-table-column
          prop="upLoadTime"
          label="上传时间"
          width="auto">
        </el-table-column>
        <el-table-column
          prop="upLoadUrl"
          label="项目链接"
          width="auto">
        </el-table-column>

<!--        <el-table-column-->
<!--          label=""-->
<!--          width="50">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button type="text" size="small" @click="handleEdit(scope.$index,uploadFileLogs)">编辑</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->

<!--        <el-table-column-->
<!--          label=""-->
<!--          width="420">-->
<!--          <template slot-scope="scope">-->
<!--            <el-button type="text" size="small" @click="deleteRow(scope.$index,uploadFileLogs)">删除</el-button>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
    </el-card>

    <el-card style="margin-top: 10px">
      <el-link href="www.baidu.com" type="info" icon="el-icon-tickets">打印提交表</el-link>
    </el-card>
  </el-col>
</template>

<script>
  import Global from '../../utils/global'
  var Type = [' ','主管','客户']
  var ResponseType = ['未处理','同意','驳回']
  export default {
    name: 'UploadFileManageSuper',
    data(){
      return{
        idx:-1,
        form:{
          sId:null,
          pId:null,
          upLoadTime:null,
          upLoadUrl:null,
        },
        input4search:'',
        glo:new Global,
        uploadFileLogs: [],
        dialogFormVisible: false,
        c:[{
          value:1,
          label:'主管',
        },{
          value:2,
          label:'客户',
        }],
        r:[{
          value:0,
          label:'未处理',
        },{
          value:1,
          label:'同意',
        }, {
          value:2,
          label: '驳回',
        }]
      }
    },
    methods:{
      handleResDel(res){
        console.log(res)
        let feedBack = eval(res);
        console.log(feedBack)
        if (feedBack.code == 20000) {
          this.$message.success(`删除成功`);
          this.projects.splice(index, 1);
        }else{
          this.$message.error(`删除失败`);
          location.reload()
        }
      },
      deleteRow(index, uploadFileLogs) {
        this.idx = index;
        var data = uploadFileLogs[index]
        this.glo.sendDate(this.glo.server + "admin/delUploadFileLogs", data, this.handleResDel,"POST")
      },

      filterByPro(value, row, column){
        const property = column['property'];
        return row[property] === value;
      },
      handleEdit(index,uploadFileLogs) {
        this.idx = index;
        this.form = uploadFileLogs[index];
        this.dialogFormVisible = true;
        // this.glo.sendDate(this.glo.server + "frontDesk/getAllClient", data, this.handleRes,"POST")
      },
      saveEdit() {
        var uploadFileLog = this.form
        this.glo.sendDate(this.glo.server + "admin/updateUploadFileLog", uploadFileLog, this.handleResEdit,"POST")
        this.dialogFormVisible = false;
      },
      handleResEdit(res){
        console.log(res)
        let feedBack = eval(res);
        console.log(feedBack)
        if (feedBack.code == 20000) {
          this.$message.success(`第 ${this.idx + 1} 行记录修改成功`);
          location.reload()
        }else{
          this.$message.error(`修改失败`);
          location.reload()
        }
      },

      inserTable (line) {
        this.uploadFileLogs.push(
          {
            sId: line.sId,
            pId:line.pId,
            upLoadTime:line.upLoadTime,
            upLoadUrl:line.upLoadUrl,
          }
        )
      },
      initUploadFileLogPage (res) {
        console.log(res)
        for (var line in res.data.uploadFileLogList){
          this.inserTable(res.data.uploadFileLogList[line])
        }
        console.log(this.tableData)

      },
      handleRes (res) {
        console.log(res);
        let feedBack = eval(res);
        if (feedBack.success == false) {//登录失败
          this.$message("上传日志获取失败");
          return;
        }
        this.$message.success("上传日志获取成功^^")
        this.initUploadFileLogPage(feedBack)
      },
    },
    mounted(){
      let data = {
        sId:JSON.parse(sessionStorage.getItem('StaffInfo')).sId
      }
      this.glo.sendDate(this.glo.server+'admin/getAllUploadFileLog',data,this.handleRes,"POST")
    },
  }
</script>

<style scoped>

</style>
